package com.xinqing.bigdata.flink.table.demo;


import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

/**
 * @Author:CHQ
 * @Date:2021/5/26 14:15
 * @Description
 */
public class Test2 {
    public static void main(String args[]) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());
        StreamTableEnvironment tableEnvironment = StreamTableEnvironment.create(env);

        tableEnvironment.createTemporaryView("input", tableEnvironment.fromDataStream(
                env.fromElements(
                        Row.of("Ailce", 12),
                        Row.of("Jay", 30),
                        Row.of("Jay", 10)))
                .as("name", "score"));


        tableEnvironment.toChangelogStream(tableEnvironment.sqlQuery("select name,sum(score) from input group by name")).print();

        env.execute();

    }

}
